<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head_latest.inc" %>
	<%--样式 --%>
	<link href="${baseURL}/themes/plugin/bootstrap/css/bootstrap.css"
		  rel="stylesheet" type="text/css"/>
	<link
			href="${baseURL}/themes/plugin/bootstrap-dialog/css/bootstrap-dialog.css"
			rel="stylesheet" type="text/css"/>
	<link href="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.css"
		  rel="stylesheet" type="text/css"/>
	<%-- 时间选择器 --%>
	<link
			href="${baseURL}/themes/plugin/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"
			rel="stylesheet" media="screen">
	<!-- 滚动条 custom scrollbar plugin -->
	<link
			href="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.css"
			rel="stylesheet" type="text/css"/>
	<link href="${baseURL}/themes/blue/css/sys.css" rel="stylesheet"
		  type="text/css"/>
	<link rel="stylesheet"
		  href="${baseURL}/assets/css/font-awesome-02.min.css"/>
	<link href="${baseURL}/themes/blue/css/fonts/iconfont.css"
		  rel="stylesheet" type="text/css"/>

	<%--八斗通用字体图标 --%>
	<link href="${baseURL}/themes/common/bd-iconfont/iconfont.css"
		  rel="stylesheet" type="text/css"/>

	<%--JS文件 --%>
	<script src="${baseURL}/js/jquerys/jquery-1.12.1.min.js"
			type="text/javascript"></script>
	<script src="${baseURL}/themes/plugin/bootstrap/js/bootstrap.min.js"
			type="text/javascript"></script>
	<script
			src="${baseURL}/themes/plugin/bootstrap-dialog/js/bootstrap-dialog.js"
			type="text/javascript"></script>


	<script
			src="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.js"
			type="text/javascript"></script>
	<script
			src="${baseURL}/themes/plugin/bootstrapTable/locale/bootstrap-table-zh-CN.min.js"
			type="text/javascript"></script>

	<!-- 滚动条 custom scrollbar plugin -->
	<script
			src="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
	<%-- 时间选择器 --%>
	<script type="text/javascript"
			src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"
			charset="UTF-8"></script>
	<script type="text/javascript"
			src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
			charset="UTF-8"></script>

	<script src="${baseURL}/js/sys-event.js" type="text/javascript"></script>

	<script src="${baseURL}/js/sdAppFrameworkCommon.js"
			type="text/javascript"></script>
	<script src="${baseURL}/js/sdAppFrameworkAddressBook.js"
			type="text/javascript"></script>
	<script src="${baseURL}/js/addressBook.js" type="text/javascript"></script>

	<script src="${baseURL}/js/ajaxfileupload.js" type="text/javascript"></script>
	<script src="${baseURL}/js/common-upload.js" type="text/javascript"></script>
	<script src="${baseURL}/js/BT.js" type="text/javascript"></script>
	<title>待办维护列表-${basePageTitle}</title>
	<style type="text/css">

		.bootstrap-dialog-message {
			text-align: center;
		}

		.bootstrap-dialog-message > p {
			text-align: center;
		}

		.bootstrap-dialog-message > h4 {
			text-align: center;
		}

		.bootstrap-dialog-footer-buttons {
			text-align: center;
		}
	</style>
</head>
<body class="FrameRightBg">
<div class="FrameRight" id="FrameRightContent">
	<!-- 这里定义了转发进入的TAB对应的菜单ID，也是TAB的属性ID值 -->
	<input type="hidden" name="menuId" id="menuId" value="${param.menuId}"/>
	<div id="mainsearch" style="width: 100%;margin-left: 0px">
		<%@ include file="/WEB-INF/jsp/module/view/new_selector_form.jsp" %>
		<form id="formsearch" method="post">
			<div class="selector-form"></div>
		</form>
	</div>
	<div class="common-option" style="margin-top: 5px">
		<div class="inner">
			<button id="add" type="button" class="btn btn-icon"
					onclick="FF_Add()">
				<i class="l-icon l-icon-a fa fa-plus-square-o"></i>新增
			</button>
			<button id="resume" type="button" class="btn btn-icon"
					onclick="FF_Edit()">
				<i class="l-icon l-icon-a fa fa-pencil-square-o"></i>修改
			</button>
			<button id="setPanel" type="button" class="btn btn-icon"
					onclick="FF_DeletedClickEvent(this)">
				<i class="l-icon l-icon-a fa fa-minus-square-o"></i>删除
			</button>
		</div>
	</div>
	<!-- 表格列表 -->
	<div class="common-table">
		<table id="maingrid" style="margin-left: 0px; width: 100%"></table>
	</div>

</div>
<script type="text/javascript">

    var handleTypeway = JSON.parse('${handleTypeway}', '{}');

    $(function () {
        $(document).keypress(function (event) {
            if (event.keyCode == 13) { // 13表示回车键
                $("#btnSearch").click();
                return false;
            }
        });
    });

    //列表结构
    function queryParams(params) {
        var p = {
            pageNo: params.pageNumber,
            perPageSize: params.pageSize,
        };
        if (selector != null) {
            var data = selector.getSelectorValue();
            for (var i = 0; i < data.length; i++) {
                var t = data[i];
                p[t.name] = t.value;
            }
        }
        return p;
    }

    function initTable() {
        $('#maingrid').bootstrapTable({
            url: '${baseURL}/engine/flow/action/batchflow/newViewFlowListJSON.do',
            method: 'post',
            contentType: "application/x-www-form-urlencoded",
            sidePagination: "server",
            queryParams: queryParams,
            queryParamsType: "undenfied",
            dataField: "Rows",
            totalField: "Total",
            striped: true,                      //是否显示行间隔色
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pagination: true,
            clickToSelect: true,                //是否启用点击选中行
            uniqueId: "id",                 //每一行的唯一标识，一般为主键列
            columns: [{
                checkbox: true
            }, {
                field: 'number',
                title: '序号',
                width: 40,
                formatter: function (value, row, index) {
                    console.log(row)
                    return (index + 1);
                }
            }, {
                field: 'code',
                title: '编码'
            }, {
                field: 'flowName',
                title: '名称'
            }, {
                field: 'commBusiName',
                title: '类别'
            }, {
                field: 'genDate',
                title: '创建时间'
            }]
        })
    }

    $(function () {
        initTable();
        $("#maingrid").css("text-align", "center");
    })

    function FF_Add() {
        window.open('${baseURL}/flow/flow_view_frame.jsp?orgId=ROOT', '流程定义');
    }

    function FF_Edit() {
        var selectedRow = $('#maingrid').bootstrapTable('getSelections');
        console.log(selectedRow)
        if (!selectedRow || selectedRow.length <= 0) {
            BT.showWarning("请选择要修改的记录！");
            return;
        }

        if (selectedRow.length > 1) {
            BT.showWarning("请选择一条记录！");
            return;
        }
        var row = selectedRow[0];

        window.open('${baseURL}/flow/flow_view_frame.jsp?flowCode=' + row.id + '&orgId=ROOT&busiId=' + row.commBusiId, '流程定义');
        parent.f_addTab("ViewDictionaryEdit", '修改流程视图', '${baseURL}/engine/flow/action/viewdictionary/edit.do?menuId=${param.menuId}&departmentId=${param.departmentId}&id=' + id);
    }

    //删除事件
    function FF_DeletedClickEvent() {
        var selectedRow = $('#maingrid').bootstrapTable('getSelections');
        if (!selectedRow || selectedRow.length <= 0) {
            alert("请选择要删除的记录");
            return false;
        }
        var arr = [];
        for (var index in selectedRow) {
            arr.push(selectedRow[index].id)
        }
        BT.showConfirm('删除', '确定删除所选的记录吗？', function () {
            $.ajax({
                type: "post",
                url: "${baseURL}/engine/flow/action/batchflow/deleteFlow2.do",
                dataType: "json",
                data: {ids: arr.join(',')},
                success: function () {
                    BT.showSuccess('删除成功！', FF_Reload);
                }
            });
        });
    }

    //一个重新加载数据方法，该方法主要作为外部框架调用使用
    function FF_Reload() {
        $("#maingrid").bootstrapTable('refresh');
    }

    // 渲染选择器
    var searchGrid = {
        $element: $('#maingrid'),
        load: function () {
            this.$element.bootstrapTable('refresh');
        }
    };

    var selector = $.initSelector(searchGrid, [
        {id: "flowName", name: "名称", value: "", isExtended: false, selectType: 1}
    ], null, null);
</script>
</body>
</html>
